<template>
    <view class="main">
        <scroll-view class="scrollview" :scroll-y="true" :style="{ height: height + 'px' }" @scrolltolower="orderScrolltolower">
            <view style="height: 30rpx "></view>
            <order :data="item" v-for="item in msg" :key="item.id" @closeS="closeShow" @_getRecoverList="_getRecoverList()" />
            <u-loadmore :status="status" :load-text="loadText" />
            <view class="scrollview-height"></view>
        </scroll-view>
    </view>
</template>

<script>
import order from './hang1.vue';
export default {
    components: {
        order
    },
    data() {
        return {
            height: 0,
            params: {
                page: 1,
                limit: 20,
                status: 1,
                //20220907
                server_id: this.$store.state.userInfo.service_id
            },
            msg:[],
            status: 'loading',
            loadText: {
                loadmore: '上拉加载更多',
                loading: '加载中...',
                nomore: '没有更多数据了'
            }
        };
    },
    onShow() {
        this._getRecoverList();
    },
    mounted() {
        const query = uni.createSelectorQuery();
        query
            .in(this)
            .select('.main')
            .boundingClientRect();
        query.exec(res => {
            this.height = uni.getSystemInfoSync().windowHeight - res[0].top - uni.upx2px(160);
        });
        this._getRecoverList();
    },
    methods: {
        // 显示弹窗，隐藏TabBar
        closeShow(data) {
            this.$emit('showtabbar');
            this.dataItem = data;
            this.isShow = true;
        },
        orderScrolltolower() {
            this.params.page++;
            this._getRecoverList();
        },
        _getRecoverList() {
            let params = {};
            this.status = 'loading';
            if (this.params.status == null) {
                params = {
                    page: this.params.page,
                    limit: this.params.limit
                };
            } else {
                params = this.params;
            }
            //这里带上server_id请求数据
            this.$u.api
                .getScanList(params)
                .then(res => {
                    //console.log("-------------getScanList");
                    //console.log(res);
                    //return false;
                    if (this.params.page == 1) {
                        this.status = 'nomore';
                        this.msg = res.list;
                    } else {
                        if (res.list <= 0) {
                            this.status = 'nomore';
                            this.params.page = this.olPage;
                            return;
                        }
                        this.olPage = this.params.page;
                        this.msg = this.msg.concat(res.list);
                    }
                })
                .catch(err => {
                    console.log(err)
                });
        }
    }
};
</script>

<style></style>
